﻿namespace Sidvall.WorkItemManager.UI.Entities
{
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling")]
    public sealed partial class WorkItem : global::Sidvall.WorkItemManager.UI.Entities.Core.BusinessBase, global::Sidvall.WorkItemManager.Data.IWorkItem
    {
        #region Business Members

        #region CanceledAction

        private global::Sidvall.WorkItemManager.Workflow.ThreadAction _CanceledAction = global::Sidvall.WorkItemManager.Workflow.ThreadAction.ContinueWithNextWorkItem;
        partial void OnBeforeCanceledActionPropertyGet(Sidvall.Business.PropertyEventData<global::Sidvall.WorkItemManager.Workflow.ThreadAction> eventData);
        partial void OnBeforeCanceledActionPropertyChanged(Sidvall.Business.PropertyChangeEventData<global::Sidvall.WorkItemManager.Workflow.ThreadAction> eventData);
        partial void OnAfterCanceledActionPropertyChanged();
        public global::Sidvall.WorkItemManager.Workflow.ThreadAction CanceledAction
        {
            get
            {
                Sidvall.Business.PropertyEventData<global::Sidvall.WorkItemManager.Workflow.ThreadAction> eventData = new Sidvall.Business.PropertyEventData<global::Sidvall.WorkItemManager.Workflow.ThreadAction>(_CanceledAction);
                OnBeforeCanceledActionPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<global::Sidvall.WorkItemManager.Workflow.ThreadAction> eventData = new Sidvall.Business.PropertyChangeEventData<global::Sidvall.WorkItemManager.Workflow.ThreadAction>(value, _CanceledAction);
                OnBeforeCanceledActionPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("CanceledAction", eventData.Value, true, true, true);
                    OnAfterCanceledActionPropertyChanged();
                }
            }
        }

        #endregion
        #region Description

        private string _Description = string.Empty;
        partial void OnBeforeDescriptionPropertyGet(Sidvall.Business.PropertyEventData<string> eventData);
        partial void OnBeforeDescriptionPropertyChanged(Sidvall.Business.PropertyChangeEventData<string> eventData);
        partial void OnAfterDescriptionPropertyChanged();
        public string Description
        {
            get
            {
                Sidvall.Business.PropertyEventData<string> eventData = new Sidvall.Business.PropertyEventData<string>(_Description);
                OnBeforeDescriptionPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<string> eventData = new Sidvall.Business.PropertyChangeEventData<string>(value, _Description);
                OnBeforeDescriptionPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("Description", eventData.Value, true, true, true);
                    OnAfterDescriptionPropertyChanged();
                }
            }
        }

        #endregion
        #region ExecutionCompletionPercentage

        private byte _ExecutionCompletionPercentage = (byte)0;
        partial void OnBeforeExecutionCompletionPercentagePropertyGet(Sidvall.Business.PropertyEventData<byte> eventData);
        partial void OnBeforeExecutionCompletionPercentagePropertyChanged(Sidvall.Business.PropertyChangeEventData<byte> eventData);
        partial void OnAfterExecutionCompletionPercentagePropertyChanged();
        public byte ExecutionCompletionPercentage
        {
            get
            {
                Sidvall.Business.PropertyEventData<byte> eventData = new Sidvall.Business.PropertyEventData<byte>(_ExecutionCompletionPercentage);
                OnBeforeExecutionCompletionPercentagePropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<byte> eventData = new Sidvall.Business.PropertyChangeEventData<byte>(value, _ExecutionCompletionPercentage);
                OnBeforeExecutionCompletionPercentagePropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("ExecutionCompletionPercentage", eventData.Value, true, true, true);
                    OnAfterExecutionCompletionPercentagePropertyChanged();
                }
            }
        }

        #endregion
        #region ExecutionContext

        private string _ExecutionContext = string.Empty;
        partial void OnBeforeExecutionContextPropertyGet(Sidvall.Business.PropertyEventData<string> eventData);
        partial void OnBeforeExecutionContextPropertyChanged(Sidvall.Business.PropertyChangeEventData<string> eventData);
        partial void OnAfterExecutionContextPropertyChanged();
        public string ExecutionContext
        {
            get
            {
                Sidvall.Business.PropertyEventData<string> eventData = new Sidvall.Business.PropertyEventData<string>(_ExecutionContext);
                OnBeforeExecutionContextPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<string> eventData = new Sidvall.Business.PropertyChangeEventData<string>(value, _ExecutionContext);
                OnBeforeExecutionContextPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("ExecutionContext", eventData.Value, true, true, true);
                    OnAfterExecutionContextPropertyChanged();
                }
            }
        }

        #endregion
        #region ExecutionContextUpdated

        private System.Nullable<System.DateTime> _ExecutionContextUpdated = null;
        partial void OnBeforeExecutionContextUpdatedPropertyGet(Sidvall.Business.PropertyEventData<System.Nullable<System.DateTime>> eventData);
        partial void OnBeforeExecutionContextUpdatedPropertyChanged(Sidvall.Business.PropertyChangeEventData<System.Nullable<System.DateTime>> eventData);
        partial void OnAfterExecutionContextUpdatedPropertyChanged();
        public System.Nullable<System.DateTime> ExecutionContextUpdated
        {
            get
            {
                Sidvall.Business.PropertyEventData<System.Nullable<System.DateTime>> eventData = new Sidvall.Business.PropertyEventData<System.Nullable<System.DateTime>>(Sidvall.Business.ValidationManager.GetValidDateTime(_ExecutionContextUpdated));
                OnBeforeExecutionContextUpdatedPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<System.Nullable<System.DateTime>> eventData = new Sidvall.Business.PropertyChangeEventData<System.Nullable<System.DateTime>>(value, _ExecutionContextUpdated);
                OnBeforeExecutionContextUpdatedPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("ExecutionContextUpdated", eventData.Value, true, true, true);
                    OnAfterExecutionContextUpdatedPropertyChanged();
                }
            }
        }

        #endregion
        #region ExecutionOrder

        private int _ExecutionOrder = 0;
        partial void OnBeforeExecutionOrderPropertyGet(Sidvall.Business.PropertyEventData<int> eventData);
        partial void OnBeforeExecutionOrderPropertyChanged(Sidvall.Business.PropertyChangeEventData<int> eventData);
        partial void OnAfterExecutionOrderPropertyChanged();
        public int ExecutionOrder
        {
            get
            {
                Sidvall.Business.PropertyEventData<int> eventData = new Sidvall.Business.PropertyEventData<int>(_ExecutionOrder);
                OnBeforeExecutionOrderPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<int> eventData = new Sidvall.Business.PropertyChangeEventData<int>(value, _ExecutionOrder);
                OnBeforeExecutionOrderPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("ExecutionOrder", eventData.Value, true, true, true);
                    OnAfterExecutionOrderPropertyChanged();
                }
            }
        }

        #endregion
        #region ExecutionStartTime

        private System.Nullable<System.DateTime> _ExecutionStartTime = null;
        partial void OnBeforeExecutionStartTimePropertyGet(Sidvall.Business.PropertyEventData<System.Nullable<System.DateTime>> eventData);
        partial void OnBeforeExecutionStartTimePropertyChanged(Sidvall.Business.PropertyChangeEventData<System.Nullable<System.DateTime>> eventData);
        partial void OnAfterExecutionStartTimePropertyChanged();
        public System.Nullable<System.DateTime> ExecutionStartTime
        {
            get
            {
                Sidvall.Business.PropertyEventData<System.Nullable<System.DateTime>> eventData = new Sidvall.Business.PropertyEventData<System.Nullable<System.DateTime>>(Sidvall.Business.ValidationManager.GetValidDateTime(_ExecutionStartTime));
                OnBeforeExecutionStartTimePropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<System.Nullable<System.DateTime>> eventData = new Sidvall.Business.PropertyChangeEventData<System.Nullable<System.DateTime>>(value, _ExecutionStartTime);
                OnBeforeExecutionStartTimePropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("ExecutionStartTime", eventData.Value, true, true, true);
                    OnAfterExecutionStartTimePropertyChanged();
                }
            }
        }

        #endregion
        #region FailedAction

        private global::Sidvall.WorkItemManager.Workflow.ThreadAction _FailedAction = global::Sidvall.WorkItemManager.Workflow.ThreadAction.ContinueWithNextWorkItem;
        partial void OnBeforeFailedActionPropertyGet(Sidvall.Business.PropertyEventData<global::Sidvall.WorkItemManager.Workflow.ThreadAction> eventData);
        partial void OnBeforeFailedActionPropertyChanged(Sidvall.Business.PropertyChangeEventData<global::Sidvall.WorkItemManager.Workflow.ThreadAction> eventData);
        partial void OnAfterFailedActionPropertyChanged();
        public global::Sidvall.WorkItemManager.Workflow.ThreadAction FailedAction
        {
            get
            {
                Sidvall.Business.PropertyEventData<global::Sidvall.WorkItemManager.Workflow.ThreadAction> eventData = new Sidvall.Business.PropertyEventData<global::Sidvall.WorkItemManager.Workflow.ThreadAction>(_FailedAction);
                OnBeforeFailedActionPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<global::Sidvall.WorkItemManager.Workflow.ThreadAction> eventData = new Sidvall.Business.PropertyChangeEventData<global::Sidvall.WorkItemManager.Workflow.ThreadAction>(value, _FailedAction);
                OnBeforeFailedActionPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("FailedAction", eventData.Value, true, true, true);
                    OnAfterFailedActionPropertyChanged();
                }
            }
        }

        #endregion
        #region FailedExecutionCount

        private int _FailedExecutionCount = 0;
        partial void OnBeforeFailedExecutionCountPropertyGet(Sidvall.Business.PropertyEventData<int> eventData);
        partial void OnBeforeFailedExecutionCountPropertyChanged(Sidvall.Business.PropertyChangeEventData<int> eventData);
        partial void OnAfterFailedExecutionCountPropertyChanged();
        public int FailedExecutionCount
        {
            get
            {
                Sidvall.Business.PropertyEventData<int> eventData = new Sidvall.Business.PropertyEventData<int>(_FailedExecutionCount);
                OnBeforeFailedExecutionCountPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<int> eventData = new Sidvall.Business.PropertyChangeEventData<int>(value, _FailedExecutionCount);
                OnBeforeFailedExecutionCountPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("FailedExecutionCount", eventData.Value, true, true, true);
                    OnAfterFailedExecutionCountPropertyChanged();
                }
            }
        }

        #endregion
        #region ForceExecution

        private bool _ForceExecution = false;
        partial void OnBeforeForceExecutionPropertyGet(Sidvall.Business.PropertyEventData<bool> eventData);
        partial void OnBeforeForceExecutionPropertyChanged(Sidvall.Business.PropertyChangeEventData<bool> eventData);
        partial void OnAfterForceExecutionPropertyChanged();
        public bool ForceExecution
        {
            get
            {
                Sidvall.Business.PropertyEventData<bool> eventData = new Sidvall.Business.PropertyEventData<bool>(_ForceExecution);
                OnBeforeForceExecutionPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<bool> eventData = new Sidvall.Business.PropertyChangeEventData<bool>(value, _ForceExecution);
                OnBeforeForceExecutionPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("ForceExecution", eventData.Value, true, true, true);
                    OnAfterForceExecutionPropertyChanged();
                }
            }
        }

        #endregion
        #region IsCanceled

        private bool _IsCanceled = false;
        partial void OnBeforeIsCanceledPropertyGet(Sidvall.Business.PropertyEventData<bool> eventData);
        partial void OnBeforeIsCanceledPropertyChanged(Sidvall.Business.PropertyChangeEventData<bool> eventData);
        partial void OnAfterIsCanceledPropertyChanged();
        public bool IsCanceled
        {
            get
            {
                Sidvall.Business.PropertyEventData<bool> eventData = new Sidvall.Business.PropertyEventData<bool>(_IsCanceled);
                OnBeforeIsCanceledPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<bool> eventData = new Sidvall.Business.PropertyChangeEventData<bool>(value, _IsCanceled);
                OnBeforeIsCanceledPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("IsCanceled", eventData.Value, true, true, true);
                    OnAfterIsCanceledPropertyChanged();
                }
            }
        }

        #endregion
        #region IsEnabled

        private bool _IsEnabled = false;
        partial void OnBeforeIsEnabledPropertyGet(Sidvall.Business.PropertyEventData<bool> eventData);
        partial void OnBeforeIsEnabledPropertyChanged(Sidvall.Business.PropertyChangeEventData<bool> eventData);
        partial void OnAfterIsEnabledPropertyChanged();
        public bool IsEnabled
        {
            get
            {
                Sidvall.Business.PropertyEventData<bool> eventData = new Sidvall.Business.PropertyEventData<bool>(_IsEnabled);
                OnBeforeIsEnabledPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<bool> eventData = new Sidvall.Business.PropertyChangeEventData<bool>(value, _IsEnabled);
                OnBeforeIsEnabledPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("IsEnabled", eventData.Value, true, true, true);
                    OnAfterIsEnabledPropertyChanged();
                }
            }
        }

        #endregion
        #region LastExecutionEndTime

        private System.Nullable<System.DateTime> _LastExecutionEndTime = null;
        partial void OnBeforeLastExecutionEndTimePropertyGet(Sidvall.Business.PropertyEventData<System.Nullable<System.DateTime>> eventData);
        partial void OnBeforeLastExecutionEndTimePropertyChanged(Sidvall.Business.PropertyChangeEventData<System.Nullable<System.DateTime>> eventData);
        partial void OnAfterLastExecutionEndTimePropertyChanged();
        public System.Nullable<System.DateTime> LastExecutionEndTime
        {
            get
            {
                Sidvall.Business.PropertyEventData<System.Nullable<System.DateTime>> eventData = new Sidvall.Business.PropertyEventData<System.Nullable<System.DateTime>>(Sidvall.Business.ValidationManager.GetValidDateTime(_LastExecutionEndTime));
                OnBeforeLastExecutionEndTimePropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<System.Nullable<System.DateTime>> eventData = new Sidvall.Business.PropertyChangeEventData<System.Nullable<System.DateTime>>(value, _LastExecutionEndTime);
                OnBeforeLastExecutionEndTimePropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("LastExecutionEndTime", eventData.Value, true, true, true);
                    OnAfterLastExecutionEndTimePropertyChanged();
                }
            }
        }

        #endregion
        #region LastExecutionStartTime

        private System.Nullable<System.DateTime> _LastExecutionStartTime = null;
        partial void OnBeforeLastExecutionStartTimePropertyGet(Sidvall.Business.PropertyEventData<System.Nullable<System.DateTime>> eventData);
        partial void OnBeforeLastExecutionStartTimePropertyChanged(Sidvall.Business.PropertyChangeEventData<System.Nullable<System.DateTime>> eventData);
        partial void OnAfterLastExecutionStartTimePropertyChanged();
        public System.Nullable<System.DateTime> LastExecutionStartTime
        {
            get
            {
                Sidvall.Business.PropertyEventData<System.Nullable<System.DateTime>> eventData = new Sidvall.Business.PropertyEventData<System.Nullable<System.DateTime>>(Sidvall.Business.ValidationManager.GetValidDateTime(_LastExecutionStartTime));
                OnBeforeLastExecutionStartTimePropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<System.Nullable<System.DateTime>> eventData = new Sidvall.Business.PropertyChangeEventData<System.Nullable<System.DateTime>>(value, _LastExecutionStartTime);
                OnBeforeLastExecutionStartTimePropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("LastExecutionStartTime", eventData.Value, true, true, true);
                    OnAfterLastExecutionStartTimePropertyChanged();
                }
            }
        }

        #endregion
        #region LastResultMessage

        private string _LastResultMessage = string.Empty;
        partial void OnBeforeLastResultMessagePropertyGet(Sidvall.Business.PropertyEventData<string> eventData);
        partial void OnBeforeLastResultMessagePropertyChanged(Sidvall.Business.PropertyChangeEventData<string> eventData);
        partial void OnAfterLastResultMessagePropertyChanged();
        public string LastResultMessage
        {
            get
            {
                Sidvall.Business.PropertyEventData<string> eventData = new Sidvall.Business.PropertyEventData<string>(_LastResultMessage);
                OnBeforeLastResultMessagePropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<string> eventData = new Sidvall.Business.PropertyChangeEventData<string>(value, _LastResultMessage);
                OnBeforeLastResultMessagePropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("LastResultMessage", eventData.Value, true, true, true);
                    OnAfterLastResultMessagePropertyChanged();
                }
            }
        }

        #endregion
        #region LastWorkItemResultId

        private System.Nullable<global::Sidvall.WorkItemManager.Workflow.WorkItemResultType> _LastWorkItemResultId = global::Sidvall.WorkItemManager.Workflow.WorkItemResultType.None;
        partial void OnBeforeLastWorkItemResultIdPropertyGet(Sidvall.Business.PropertyEventData<System.Nullable<global::Sidvall.WorkItemManager.Workflow.WorkItemResultType>> eventData);
        partial void OnBeforeLastWorkItemResultIdPropertyChanged(Sidvall.Business.PropertyChangeEventData<System.Nullable<global::Sidvall.WorkItemManager.Workflow.WorkItemResultType>> eventData);
        partial void OnAfterLastWorkItemResultIdPropertyChanged();
        public System.Nullable<global::Sidvall.WorkItemManager.Workflow.WorkItemResultType> LastWorkItemResultId
        {
            get
            {
                Sidvall.Business.PropertyEventData<System.Nullable<global::Sidvall.WorkItemManager.Workflow.WorkItemResultType>> eventData = new Sidvall.Business.PropertyEventData<System.Nullable<global::Sidvall.WorkItemManager.Workflow.WorkItemResultType>>(_LastWorkItemResultId);
                OnBeforeLastWorkItemResultIdPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<System.Nullable<global::Sidvall.WorkItemManager.Workflow.WorkItemResultType>> eventData = new Sidvall.Business.PropertyChangeEventData<System.Nullable<global::Sidvall.WorkItemManager.Workflow.WorkItemResultType>>(value, _LastWorkItemResultId);
                OnBeforeLastWorkItemResultIdPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("LastWorkItemResultId", eventData.Value, true, true, true);
                    OnAfterLastWorkItemResultIdPropertyChanged();
                }
            }
        }

        #endregion
        #region LogDayCount

        private int _LogDayCount = 0;
        partial void OnBeforeLogDayCountPropertyGet(Sidvall.Business.PropertyEventData<int> eventData);
        partial void OnBeforeLogDayCountPropertyChanged(Sidvall.Business.PropertyChangeEventData<int> eventData);
        partial void OnAfterLogDayCountPropertyChanged();
        public int LogDayCount
        {
            get
            {
                Sidvall.Business.PropertyEventData<int> eventData = new Sidvall.Business.PropertyEventData<int>(_LogDayCount);
                OnBeforeLogDayCountPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<int> eventData = new Sidvall.Business.PropertyChangeEventData<int>(value, _LogDayCount);
                OnBeforeLogDayCountPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("LogDayCount", eventData.Value, true, true, true);
                    OnAfterLogDayCountPropertyChanged();
                }
            }
        }

        #endregion
        #region LogModeId

        private global::Sidvall.WorkItemManager.Workflow.LogModes _LogModeId = global::Sidvall.WorkItemManager.Workflow.LogModes.LogAll;
        partial void OnBeforeLogModeIdPropertyGet(Sidvall.Business.PropertyEventData<global::Sidvall.WorkItemManager.Workflow.LogModes> eventData);
        partial void OnBeforeLogModeIdPropertyChanged(Sidvall.Business.PropertyChangeEventData<global::Sidvall.WorkItemManager.Workflow.LogModes> eventData);
        partial void OnAfterLogModeIdPropertyChanged();
        public global::Sidvall.WorkItemManager.Workflow.LogModes LogModeId
        {
            get
            {
                Sidvall.Business.PropertyEventData<global::Sidvall.WorkItemManager.Workflow.LogModes> eventData = new Sidvall.Business.PropertyEventData<global::Sidvall.WorkItemManager.Workflow.LogModes>(_LogModeId);
                OnBeforeLogModeIdPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<global::Sidvall.WorkItemManager.Workflow.LogModes> eventData = new Sidvall.Business.PropertyChangeEventData<global::Sidvall.WorkItemManager.Workflow.LogModes>(value, _LogModeId);
                OnBeforeLogModeIdPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("LogModeId", eventData.Value, true, true, true);
                    OnAfterLogModeIdPropertyChanged();
                }
            }
        }

        #endregion
        #region Name

        private string _Name = string.Empty;
        partial void OnBeforeNamePropertyGet(Sidvall.Business.PropertyEventData<string> eventData);
        partial void OnBeforeNamePropertyChanged(Sidvall.Business.PropertyChangeEventData<string> eventData);
        partial void OnAfterNamePropertyChanged();
        public string Name
        {
            get
            {
                Sidvall.Business.PropertyEventData<string> eventData = new Sidvall.Business.PropertyEventData<string>(_Name);
                OnBeforeNamePropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<string> eventData = new Sidvall.Business.PropertyChangeEventData<string>(value, _Name);
                OnBeforeNamePropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("Name", eventData.Value, true, true, true);
                    OnAfterNamePropertyChanged();
                }
            }
        }

        #endregion
        #region RetryCount

        private int _RetryCount = 0;
        partial void OnBeforeRetryCountPropertyGet(Sidvall.Business.PropertyEventData<int> eventData);
        partial void OnBeforeRetryCountPropertyChanged(Sidvall.Business.PropertyChangeEventData<int> eventData);
        partial void OnAfterRetryCountPropertyChanged();
        public int RetryCount
        {
            get
            {
                Sidvall.Business.PropertyEventData<int> eventData = new Sidvall.Business.PropertyEventData<int>(_RetryCount);
                OnBeforeRetryCountPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<int> eventData = new Sidvall.Business.PropertyChangeEventData<int>(value, _RetryCount);
                OnBeforeRetryCountPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("RetryCount", eventData.Value, true, true, true);
                    OnAfterRetryCountPropertyChanged();
                }
            }
        }

        #endregion
        #region RetryTime

        private System.Nullable<System.DateTime> _RetryTime = null;
        partial void OnBeforeRetryTimePropertyGet(Sidvall.Business.PropertyEventData<System.Nullable<System.DateTime>> eventData);
        partial void OnBeforeRetryTimePropertyChanged(Sidvall.Business.PropertyChangeEventData<System.Nullable<System.DateTime>> eventData);
        partial void OnAfterRetryTimePropertyChanged();
        public System.Nullable<System.DateTime> RetryTime
        {
            get
            {
                Sidvall.Business.PropertyEventData<System.Nullable<System.DateTime>> eventData = new Sidvall.Business.PropertyEventData<System.Nullable<System.DateTime>>(Sidvall.Business.ValidationManager.GetValidDateTime(_RetryTime));
                OnBeforeRetryTimePropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<System.Nullable<System.DateTime>> eventData = new Sidvall.Business.PropertyChangeEventData<System.Nullable<System.DateTime>>(value, _RetryTime);
                OnBeforeRetryTimePropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("RetryTime", eventData.Value, true, true, true);
                    OnAfterRetryTimePropertyChanged();
                }
            }
        }

        #endregion
        #region SensorLogDayCount

        private int _SensorLogDayCount = 0;
        partial void OnBeforeSensorLogDayCountPropertyGet(Sidvall.Business.PropertyEventData<int> eventData);
        partial void OnBeforeSensorLogDayCountPropertyChanged(Sidvall.Business.PropertyChangeEventData<int> eventData);
        partial void OnAfterSensorLogDayCountPropertyChanged();
        public int SensorLogDayCount
        {
            get
            {
                Sidvall.Business.PropertyEventData<int> eventData = new Sidvall.Business.PropertyEventData<int>(_SensorLogDayCount);
                OnBeforeSensorLogDayCountPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<int> eventData = new Sidvall.Business.PropertyChangeEventData<int>(value, _SensorLogDayCount);
                OnBeforeSensorLogDayCountPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("SensorLogDayCount", eventData.Value, true, true, true);
                    OnAfterSensorLogDayCountPropertyChanged();
                }
            }
        }

        #endregion
        #region WorkerId

        private long _WorkerId = 0L;
        partial void OnBeforeWorkerIdPropertyGet(Sidvall.Business.PropertyEventData<long> eventData);
        partial void OnBeforeWorkerIdPropertyChanged(Sidvall.Business.PropertyChangeEventData<long> eventData);
        partial void OnAfterWorkerIdPropertyChanged();
        public long WorkerId
        {
            get
            {
                Sidvall.Business.PropertyEventData<long> eventData = new Sidvall.Business.PropertyEventData<long>(_WorkerId);
                OnBeforeWorkerIdPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<long> eventData = new Sidvall.Business.PropertyChangeEventData<long>(value, _WorkerId);
                OnBeforeWorkerIdPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("WorkerId", eventData.Value, true, true, true);
                    OnAfterWorkerIdPropertyChanged();
                }
            }
        }

        #endregion
        #region WorkItemContext

        private string _WorkItemContext = string.Empty;
        partial void OnBeforeWorkItemContextPropertyGet(Sidvall.Business.PropertyEventData<string> eventData);
        partial void OnBeforeWorkItemContextPropertyChanged(Sidvall.Business.PropertyChangeEventData<string> eventData);
        partial void OnAfterWorkItemContextPropertyChanged();
        public string WorkItemContext
        {
            get
            {
                Sidvall.Business.PropertyEventData<string> eventData = new Sidvall.Business.PropertyEventData<string>(_WorkItemContext);
                OnBeforeWorkItemContextPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<string> eventData = new Sidvall.Business.PropertyChangeEventData<string>(value, _WorkItemContext);
                OnBeforeWorkItemContextPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("WorkItemContext", eventData.Value, true, true, true);
                    OnAfterWorkItemContextPropertyChanged();
                }
            }
        }

        #endregion
        #region WorkItemId

        private System.Nullable<long> _WorkItemId = null;
        partial void OnBeforeWorkItemIdPropertyGet(Sidvall.Business.PropertyEventData<System.Nullable<long>> eventData);
        partial void OnBeforeWorkItemIdPropertyChanged(Sidvall.Business.PropertyChangeEventData<System.Nullable<long>> eventData);
        partial void OnAfterWorkItemIdPropertyChanged();
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
        public System.Nullable<long> WorkItemId
        {
            get
            {
                Sidvall.Business.PropertyEventData<System.Nullable<long>> eventData = new Sidvall.Business.PropertyEventData<System.Nullable<long>>(_WorkItemId);
                OnBeforeWorkItemIdPropertyGet(eventData);
                return eventData.Value;
            }
            internal set
            {
                Sidvall.Business.PropertyChangeEventData<System.Nullable<long>> eventData = new Sidvall.Business.PropertyChangeEventData<System.Nullable<long>>(value, _WorkItemId);
                OnBeforeWorkItemIdPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("WorkItemId", eventData.Value, true, true, true);
                    OnAfterWorkItemIdPropertyChanged();
                }
            }
        }

        #endregion
        #region WorkItemStatusId

        private global::Sidvall.WorkItemManager.Workflow.WorkItemStatus _WorkItemStatusId = global::Sidvall.WorkItemManager.Workflow.WorkItemStatus.Idle;
        partial void OnBeforeWorkItemStatusIdPropertyGet(Sidvall.Business.PropertyEventData<global::Sidvall.WorkItemManager.Workflow.WorkItemStatus> eventData);
        partial void OnBeforeWorkItemStatusIdPropertyChanged(Sidvall.Business.PropertyChangeEventData<global::Sidvall.WorkItemManager.Workflow.WorkItemStatus> eventData);
        partial void OnAfterWorkItemStatusIdPropertyChanged();
        public global::Sidvall.WorkItemManager.Workflow.WorkItemStatus WorkItemStatusId
        {
            get
            {
                Sidvall.Business.PropertyEventData<global::Sidvall.WorkItemManager.Workflow.WorkItemStatus> eventData = new Sidvall.Business.PropertyEventData<global::Sidvall.WorkItemManager.Workflow.WorkItemStatus>(_WorkItemStatusId);
                OnBeforeWorkItemStatusIdPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<global::Sidvall.WorkItemManager.Workflow.WorkItemStatus> eventData = new Sidvall.Business.PropertyChangeEventData<global::Sidvall.WorkItemManager.Workflow.WorkItemStatus>(value, _WorkItemStatusId);
                OnBeforeWorkItemStatusIdPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("WorkItemStatusId", eventData.Value, true, true, true);
                    OnAfterWorkItemStatusIdPropertyChanged();
                }
            }
        }

        #endregion
        #region WorkItemTypeId

        private System.Nullable<long> _WorkItemTypeId = null;
        partial void OnBeforeWorkItemTypeIdPropertyGet(Sidvall.Business.PropertyEventData<System.Nullable<long>> eventData);
        partial void OnBeforeWorkItemTypeIdPropertyChanged(Sidvall.Business.PropertyChangeEventData<System.Nullable<long>> eventData);
        partial void OnAfterWorkItemTypeIdPropertyChanged();
        public System.Nullable<long> WorkItemTypeId
        {
            get
            {
                Sidvall.Business.PropertyEventData<System.Nullable<long>> eventData = new Sidvall.Business.PropertyEventData<System.Nullable<long>>(_WorkItemTypeId);
                OnBeforeWorkItemTypeIdPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<System.Nullable<long>> eventData = new Sidvall.Business.PropertyChangeEventData<System.Nullable<long>>(value, _WorkItemTypeId);
                OnBeforeWorkItemTypeIdPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("WorkItemTypeId", eventData.Value, true, true, true);
                    OnAfterWorkItemTypeIdPropertyChanged();
                }
            }
        }

        #endregion
        #region WorkRetryPolicyContext

        private string _WorkRetryPolicyContext = string.Empty;
        partial void OnBeforeWorkRetryPolicyContextPropertyGet(Sidvall.Business.PropertyEventData<string> eventData);
        partial void OnBeforeWorkRetryPolicyContextPropertyChanged(Sidvall.Business.PropertyChangeEventData<string> eventData);
        partial void OnAfterWorkRetryPolicyContextPropertyChanged();
        public string WorkRetryPolicyContext
        {
            get
            {
                Sidvall.Business.PropertyEventData<string> eventData = new Sidvall.Business.PropertyEventData<string>(_WorkRetryPolicyContext);
                OnBeforeWorkRetryPolicyContextPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<string> eventData = new Sidvall.Business.PropertyChangeEventData<string>(value, _WorkRetryPolicyContext);
                OnBeforeWorkRetryPolicyContextPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("WorkRetryPolicyContext", eventData.Value, true, true, true);
                    OnAfterWorkRetryPolicyContextPropertyChanged();
                }
            }
        }

        #endregion
        #region WorkRetryPolicyId

        private System.Nullable<long> _WorkRetryPolicyId = null;
        partial void OnBeforeWorkRetryPolicyIdPropertyGet(Sidvall.Business.PropertyEventData<System.Nullable<long>> eventData);
        partial void OnBeforeWorkRetryPolicyIdPropertyChanged(Sidvall.Business.PropertyChangeEventData<System.Nullable<long>> eventData);
        partial void OnAfterWorkRetryPolicyIdPropertyChanged();
        public System.Nullable<long> WorkRetryPolicyId
        {
            get
            {
                Sidvall.Business.PropertyEventData<System.Nullable<long>> eventData = new Sidvall.Business.PropertyEventData<System.Nullable<long>>(_WorkRetryPolicyId);
                OnBeforeWorkRetryPolicyIdPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<System.Nullable<long>> eventData = new Sidvall.Business.PropertyChangeEventData<System.Nullable<long>>(value, _WorkRetryPolicyId);
                OnBeforeWorkRetryPolicyIdPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("WorkRetryPolicyId", eventData.Value, true, true, true);
                    OnAfterWorkRetryPolicyIdPropertyChanged();
                }
            }
        }

        #endregion
        #region ServerConnectionId

        private System.Nullable<System.Int32> _ServerConnectionId = null;
        partial void OnBeforeServerConnectionIdPropertyGet(Sidvall.Business.PropertyEventData<System.Nullable<System.Int32>> eventData);
        partial void OnBeforeServerConnectionIdPropertyChanged(Sidvall.Business.PropertyChangeEventData<System.Nullable<System.Int32>> eventData);
        partial void OnAfterServerConnectionIdPropertyChanged();
        public System.Nullable<System.Int32> ServerConnectionId
        {
            get
            {
                Sidvall.Business.PropertyEventData<System.Nullable<System.Int32>> eventData = new Sidvall.Business.PropertyEventData<System.Nullable<System.Int32>>(_ServerConnectionId);
                OnBeforeServerConnectionIdPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<System.Nullable<System.Int32>> eventData = new Sidvall.Business.PropertyChangeEventData<System.Nullable<System.Int32>>(value, _ServerConnectionId);
                OnBeforeServerConnectionIdPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("ServerConnectionId", eventData.Value, true, true, true);
                    OnAfterServerConnectionIdPropertyChanged();
                }
            }
        }

        #endregion
        #region Worker

        private Worker _Worker;
        partial void OnBeforeWorkerPropertyChanged(Sidvall.Business.PropertyChangeEventData<Worker> eventData);
        partial void OnAfterWorkerPropertyChanged();
        public Worker Worker
        {
            get
            {
                return _Worker;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<Worker> eventData = new Sidvall.Business.PropertyChangeEventData<Worker>(value, _Worker);
                OnBeforeWorkerPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("Worker", eventData.Value, true, true, false);
                    OnAfterWorkerPropertyChanged();
                }
            }
        }

        #endregion
        #region WorkItemLogs

        private WorkItemLogCollection _WorkItemLogs;
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
        public WorkItemLogCollection WorkItemLogs
        {
            get
            {
                return _WorkItemLogs;
            }
            internal set
            {
                LoadInstanceField("WorkItemLogs", value, true, false, false);
            }
        }

        #endregion
        #region WorkItemSensors

        private WorkItemSensorCollection _WorkItemSensors;
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
        public WorkItemSensorCollection WorkItemSensors
        {
            get
            {
                return _WorkItemSensors;
            }
            internal set
            {
                LoadInstanceField("WorkItemSensors", value, true, false, false);
            }
        }

        #endregion
        #region WorkItemType

        private WorkItemType _WorkItemType;
        partial void OnBeforeWorkItemTypePropertyChanged(Sidvall.Business.PropertyChangeEventData<WorkItemType> eventData);
        partial void OnAfterWorkItemTypePropertyChanged();
        public WorkItemType WorkItemType
        {
            get
            {
                return _WorkItemType;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<WorkItemType> eventData = new Sidvall.Business.PropertyChangeEventData<WorkItemType>(value, _WorkItemType);
                OnBeforeWorkItemTypePropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("WorkItemType", eventData.Value, true, true, false);
                    OnAfterWorkItemTypePropertyChanged();
                }
            }
        }

        #endregion
        #region WorkItemWorkConditions

        private WorkItemWorkConditionCollection _WorkItemWorkConditions;
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
        public WorkItemWorkConditionCollection WorkItemWorkConditions
        {
            get
            {
                return _WorkItemWorkConditions;
            }
            internal set
            {
                LoadInstanceField("WorkItemWorkConditions", value, true, false, false);
            }
        }

        #endregion
        #region WorkRetryPolicy

        private WorkRetryPolicy _WorkRetryPolicy;
        partial void OnBeforeWorkRetryPolicyPropertyChanged(Sidvall.Business.PropertyChangeEventData<WorkRetryPolicy> eventData);
        partial void OnAfterWorkRetryPolicyPropertyChanged();
        public WorkRetryPolicy WorkRetryPolicy
        {
            get
            {
                return _WorkRetryPolicy;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<WorkRetryPolicy> eventData = new Sidvall.Business.PropertyChangeEventData<WorkRetryPolicy>(value, _WorkRetryPolicy);
                OnBeforeWorkRetryPolicyPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("WorkRetryPolicy", eventData.Value, true, true, false);
                    OnAfterWorkRetryPolicyPropertyChanged();
                }
            }
        }

        #endregion
        #region DataRowContextStorageKey

        protected override string DataRowContextStorageKey
        {
            get
            {
                return global::Sidvall.WorkItemManager.UI.SystemContext.Current.EntityFacade.WorkItemManager.GetKey(this);
            }
        }

        #endregion
        #region DataRowIsValid

        public override bool DataRowIsValid(Sidvall.Data.BusinessRuleFilter filter)
        {
            return global::Sidvall.WorkItemManager.UI.SystemContext.Current.EntityFacade.WorkItemManager.DataRowIsValid(this, filter);
        }

        #endregion
        #region DataRowStateIsDirty

        public override bool DataRowStateIsDirty
        {
            get
            {
                return global::Sidvall.WorkItemManager.UI.SystemContext.Current.EntityFacade.WorkItemManager.DataRowStateIsDirty(this);
            }
        }

        #endregion

        #region LoadWorkItemLogs

        public void LoadWorkItemLogs(WorkItemLogCollection value)
        {
            LoadInstanceField("WorkItemLogs", value, true, true, false);
        }

        #endregion
        #region LoadWorkItemSensors

        public void LoadWorkItemSensors(WorkItemSensorCollection value)
        {
            LoadInstanceField("WorkItemSensors", value, true, true, false);
        }

        #endregion
        #region LoadWorkItemWorkConditions

        public void LoadWorkItemWorkConditions(WorkItemWorkConditionCollection value)
        {
            LoadInstanceField("WorkItemWorkConditions", value, true, true, false);
        }

        #endregion
        #region LoadWorkItemLogsAsync

        public async System.Threading.Tasks.Task<WorkItemLogCollection> LoadWorkItemLogsAsync()
        {
            return await LoadWorkItemLogsAsync(false, true, null, null, null);
        }
        public async System.Threading.Tasks.Task<WorkItemLogCollection> LoadWorkItemLogsAsync(bool refresh, bool raisePropertyChanged, global::Sidvall.Data.FetchListCriteria<global::Sidvall.WorkItemManager.Data.Fields.WorkItemLogField, global::Sidvall.WorkItemManager.Data.Relations.WorkItemLogRelation> criteria, string strategyContext, global::Sidvall.Data.ObjectParameterCollection objectParameters)
        {
            await global::Sidvall.WorkItemManager.UI.SystemContext.Current.DataPortal.WorkItemManager.LoadWorkItemLogsAsync(this, refresh, raisePropertyChanged, criteria, strategyContext, objectParameters);

            return this.WorkItemLogs;
        }

        #endregion
        #region LoadWorkItemSensorsAsync

        public async System.Threading.Tasks.Task<WorkItemSensorCollection> LoadWorkItemSensorsAsync()
        {
            return await LoadWorkItemSensorsAsync(false, true, null, null, null);
        }
        public async System.Threading.Tasks.Task<WorkItemSensorCollection> LoadWorkItemSensorsAsync(bool refresh, bool raisePropertyChanged, global::Sidvall.Data.FetchListCriteria<global::Sidvall.WorkItemManager.Data.Fields.WorkItemSensorField, global::Sidvall.WorkItemManager.Data.Relations.WorkItemSensorRelation> criteria, string strategyContext, global::Sidvall.Data.ObjectParameterCollection objectParameters)
        {
            await global::Sidvall.WorkItemManager.UI.SystemContext.Current.DataPortal.WorkItemManager.LoadWorkItemSensorsAsync(this, refresh, raisePropertyChanged, criteria, strategyContext, objectParameters);

            return this.WorkItemSensors;
        }

        #endregion
        #region LoadWorkItemWorkConditionsAsync

        public async System.Threading.Tasks.Task<WorkItemWorkConditionCollection> LoadWorkItemWorkConditionsAsync()
        {
            return await LoadWorkItemWorkConditionsAsync(false, true, null, null, null);
        }
        public async System.Threading.Tasks.Task<WorkItemWorkConditionCollection> LoadWorkItemWorkConditionsAsync(bool refresh, bool raisePropertyChanged, global::Sidvall.Data.FetchListCriteria<global::Sidvall.WorkItemManager.Data.Fields.WorkItemWorkConditionField, global::Sidvall.WorkItemManager.Data.Relations.WorkItemWorkConditionRelation> criteria, string strategyContext, global::Sidvall.Data.ObjectParameterCollection objectParameters)
        {
            await global::Sidvall.WorkItemManager.UI.SystemContext.Current.DataPortal.WorkItemManager.LoadWorkItemWorkConditionsAsync(this, refresh, raisePropertyChanged, criteria, strategyContext, objectParameters);

            return this.WorkItemWorkConditions;
        }

        #endregion
        #region LoadWorkerAsync

        public async System.Threading.Tasks.Task<Worker> LoadWorkerAsync()
        {
            return await LoadWorkerAsync(false, true, null, null, null);
        }
        public async System.Threading.Tasks.Task<Worker> LoadWorkerAsync(bool refresh, bool raisePropertyChanged, global::Sidvall.Data.FetchCriteria<global::Sidvall.WorkItemManager.Data.Fields.WorkerField, global::Sidvall.WorkItemManager.Data.Relations.WorkerRelation> criteria, string strategyContext, global::Sidvall.Data.ObjectParameterCollection objectParameters)
        {
            await global::Sidvall.WorkItemManager.UI.SystemContext.Current.DataPortal.WorkItemManager.LoadWorkerAsync(this, refresh, raisePropertyChanged, criteria, strategyContext, objectParameters);

            return this.Worker;
        }
        public Worker LoadWorker(Worker item)
        {
            LoadInstanceField("Worker", item, true, true, false);
            return item;
        }

        #endregion
        #region LoadWorkItemTypeAsync

        public async System.Threading.Tasks.Task<WorkItemType> LoadWorkItemTypeAsync()
        {
            return await LoadWorkItemTypeAsync(false, true, null, null, null);
        }
        public async System.Threading.Tasks.Task<WorkItemType> LoadWorkItemTypeAsync(bool refresh, bool raisePropertyChanged, global::Sidvall.Data.FetchCriteria<global::Sidvall.WorkItemManager.Data.Fields.WorkItemTypeField, global::Sidvall.WorkItemManager.Data.Relations.WorkItemTypeRelation> criteria, string strategyContext, global::Sidvall.Data.ObjectParameterCollection objectParameters)
        {
            await global::Sidvall.WorkItemManager.UI.SystemContext.Current.DataPortal.WorkItemManager.LoadWorkItemTypeAsync(this, refresh, raisePropertyChanged, criteria, strategyContext, objectParameters);

            return this.WorkItemType;
        }
        public WorkItemType LoadWorkItemType(WorkItemType item)
        {
            LoadInstanceField("WorkItemType", item, true, true, false);
            return item;
        }

        #endregion
        #region LoadWorkRetryPolicyAsync

        public async System.Threading.Tasks.Task<WorkRetryPolicy> LoadWorkRetryPolicyAsync()
        {
            return await LoadWorkRetryPolicyAsync(false, true, null, null, null);
        }
        public async System.Threading.Tasks.Task<WorkRetryPolicy> LoadWorkRetryPolicyAsync(bool refresh, bool raisePropertyChanged, global::Sidvall.Data.FetchCriteria<global::Sidvall.WorkItemManager.Data.Fields.WorkRetryPolicyField, global::Sidvall.WorkItemManager.Data.Relations.WorkRetryPolicyRelation> criteria, string strategyContext, global::Sidvall.Data.ObjectParameterCollection objectParameters)
        {
            await global::Sidvall.WorkItemManager.UI.SystemContext.Current.DataPortal.WorkItemManager.LoadWorkRetryPolicyAsync(this, refresh, raisePropertyChanged, criteria, strategyContext, objectParameters);

            return this.WorkRetryPolicy;
        }
        public WorkRetryPolicy LoadWorkRetryPolicy(WorkRetryPolicy item)
        {
            LoadInstanceField("WorkRetryPolicy", item, true, true, false);
            return item;
        }

        #endregion
        #region LoadInstanceField

        public void LoadInstanceField(string fieldName, object value, bool cascade, bool raisePropertyChanged, bool updateState)
        {
            global::Sidvall.WorkItemManager.UI.SystemContext.Current.EntityFacade.WorkItemManager.LoadInstanceField(this, fieldName, value, cascade, raisePropertyChanged, updateState);
        }

        #endregion
        #region AcceptChanges

        public void AcceptChanges()
        {
            global::Sidvall.WorkItemManager.UI.SystemContext.Current.EntityFacade.WorkItemManager.AcceptChanges(this);
        }

        #endregion
        #region Clone

        public WorkItem Clone()
        {
            var copySettings = Sidvall.Data.CopySettings.Clone();
            return Copy(copySettings);
        }

        #endregion
        #region Copy

        public WorkItem Copy()
        {
            return Copy(null);
        }
        public WorkItem Copy(Sidvall.Data.CopySettings copySettings)
        {
            if (copySettings == null)
                copySettings = new Sidvall.Data.CopySettings();
            if (!Sidvall.Data.DataRowContextManager.IsValid(this, copySettings.RowFilter))
                return null;
            var item = new WorkItem();
            Import(item, this, copySettings);
            return item;
        }

        #endregion
        #region Import

        public void Import(global::Sidvall.WorkItemManager.Data.IWorkItem item)
        {
            Import(item, null);
        }
        public void Import(global::Sidvall.WorkItemManager.Data.IWorkItem item, Sidvall.Data.CopySettings copySettings)
        {
            Import(this, item, copySettings);
        }
        partial void OnAfterImport(WorkItem destination, global::Sidvall.WorkItemManager.Data.IWorkItem source, Sidvall.Data.CopySettings copySettings);
        private void Import(WorkItem destination, global::Sidvall.WorkItemManager.Data.IWorkItem source, Sidvall.Data.CopySettings copySettings)
        {
            global::Sidvall.WorkItemManager.UI.SystemContext.Current.EntityFacade.WorkItemManager.Import(destination, source, copySettings);
            OnAfterImport(destination, source, copySettings);
        }
        partial void OnAfterImport(WorkItem destination, WorkItem source, Sidvall.Data.CopySettings copySettings);
        private void Import(WorkItem destination, WorkItem source, Sidvall.Data.CopySettings copySettings)
        {
            Import(destination, source as global::Sidvall.WorkItemManager.Data.IWorkItem, copySettings);
            OnAfterImport(destination, source, copySettings);
        }

        #endregion
        #region SaveItemAsync

        public async System.Threading.Tasks.Task<WorkItem> SaveItemAsync()
        {
            return await global::Sidvall.WorkItemManager.UI.SystemContext.Current.DataPortal.WorkItemManager.SaveItemAsync(this);
        }
        public async System.Threading.Tasks.Task<WorkItem> SaveItemAsync(Sidvall.Data.SaveMode mode)
        {
            return await global::Sidvall.WorkItemManager.UI.SystemContext.Current.DataPortal.WorkItemManager.SaveItemAsync(this, mode);
        }
        public async System.Threading.Tasks.Task<WorkItem> SaveItemAsync(Sidvall.Data.SaveSettings settings)
        {
            return await global::Sidvall.WorkItemManager.UI.SystemContext.Current.DataPortal.WorkItemManager.SaveItemAsync(this, settings);
        }
        public async System.Threading.Tasks.Task<WorkItem> SaveItemAsync(Sidvall.Data.SaveSettings settings, string strategyContext, global::Sidvall.Data.ObjectParameterCollection objectParameters)
        {
            return await global::Sidvall.WorkItemManager.UI.SystemContext.Current.DataPortal.WorkItemManager.SaveItemAsync(this, settings, strategyContext, objectParameters);
        }

        #endregion
        #region ValidateAsync

        public async System.Threading.Tasks.Task<Sidvall.Data.BusinessRuleCollection> ValidateAsync()
        {
            return await ValidateAsync((Sidvall.Data.ValidationSettings)null);
        }
        public async System.Threading.Tasks.Task<Sidvall.Data.BusinessRuleCollection> ValidateAsync(Sidvall.Data.ValidationSettings settings)
        {
            var context = new Sidvall.Business.ValidationContext(settings);
            await global::Sidvall.WorkItemManager.UI.SystemContext.Current.EntityFacade.WorkItemManager.ValidateAsync(this, context);
            await ValidateAsync(context);
            return context.AllBusinessRules;
        }
        partial void OnAfterValidate(Sidvall.Data.BusinessRuleCollection itemBusinessRules, Sidvall.Business.ValidationContext context);
        public async System.Threading.Tasks.Task ValidateAsync(Sidvall.Business.ValidationContext context)
        {
            var itemBusinessRules = new Sidvall.Data.BusinessRuleCollection();
            OnAfterValidate(itemBusinessRules, context);
            await context.TaskContext.DoTaskAsync();
            context.AllBusinessRules.AddRange(context.Settings.IncludeNotBrokenRules, itemBusinessRules);
            var businessRulesProvider = this as Sidvall.Data.IBusinessRulesProvider;
            if (businessRulesProvider != null)
                businessRulesProvider.BusinessRules.AddRange(context.Settings.IncludeNotBrokenRules, itemBusinessRules);
        }

        #endregion
        #region Initialize

        public void Initialize()
        {
            global::Sidvall.WorkItemManager.UI.SystemContext.Current.EntityFacade.WorkItemManager.Initialize(this);
        }
        public void Initialize(Sidvall.Data.InitializeSettings settings)
        {
            global::Sidvall.WorkItemManager.UI.SystemContext.Current.EntityFacade.WorkItemManager.Initialize(this, settings);
        }

        #endregion
        
        #region IWorkItem Members

        global::Sidvall.WorkItemManager.Workflow.ThreadAction global::Sidvall.WorkItemManager.Data.IWorkItem.CanceledAction
        {
            get
            {
                return this._CanceledAction;
            }
            set
            {
                this._CanceledAction = value;
            }
        }
        string global::Sidvall.WorkItemManager.Data.IWorkItem.Description
        {
            get
            {
                return this._Description;
            }
            set
            {
                this._Description = value;
            }
        }
        byte global::Sidvall.WorkItemManager.Data.IWorkItem.ExecutionCompletionPercentage
        {
            get
            {
                return this._ExecutionCompletionPercentage;
            }
            set
            {
                this._ExecutionCompletionPercentage = value;
            }
        }
        string global::Sidvall.WorkItemManager.Data.IWorkItem.ExecutionContext
        {
            get
            {
                return this._ExecutionContext;
            }
            set
            {
                this._ExecutionContext = value;
            }
        }
        System.Nullable<System.DateTime> global::Sidvall.WorkItemManager.Data.IWorkItem.ExecutionContextUpdated
        {
            get
            {
                return this._ExecutionContextUpdated;
            }
            set
            {
                this._ExecutionContextUpdated = value;
            }
        }
        int global::Sidvall.WorkItemManager.Data.IWorkItem.ExecutionOrder
        {
            get
            {
                return this._ExecutionOrder;
            }
            set
            {
                this._ExecutionOrder = value;
            }
        }
        System.Nullable<System.DateTime> global::Sidvall.WorkItemManager.Data.IWorkItem.ExecutionStartTime
        {
            get
            {
                return this._ExecutionStartTime;
            }
            set
            {
                this._ExecutionStartTime = value;
            }
        }
        global::Sidvall.WorkItemManager.Workflow.ThreadAction global::Sidvall.WorkItemManager.Data.IWorkItem.FailedAction
        {
            get
            {
                return this._FailedAction;
            }
            set
            {
                this._FailedAction = value;
            }
        }
        int global::Sidvall.WorkItemManager.Data.IWorkItem.FailedExecutionCount
        {
            get
            {
                return this._FailedExecutionCount;
            }
            set
            {
                this._FailedExecutionCount = value;
            }
        }
        bool global::Sidvall.WorkItemManager.Data.IWorkItem.ForceExecution
        {
            get
            {
                return this._ForceExecution;
            }
            set
            {
                this._ForceExecution = value;
            }
        }
        bool global::Sidvall.WorkItemManager.Data.IWorkItem.IsCanceled
        {
            get
            {
                return this._IsCanceled;
            }
            set
            {
                this._IsCanceled = value;
            }
        }
        bool global::Sidvall.WorkItemManager.Data.IWorkItem.IsEnabled
        {
            get
            {
                return this._IsEnabled;
            }
            set
            {
                this._IsEnabled = value;
            }
        }
        System.Nullable<System.DateTime> global::Sidvall.WorkItemManager.Data.IWorkItem.LastExecutionEndTime
        {
            get
            {
                return this._LastExecutionEndTime;
            }
            set
            {
                this._LastExecutionEndTime = value;
            }
        }
        System.Nullable<System.DateTime> global::Sidvall.WorkItemManager.Data.IWorkItem.LastExecutionStartTime
        {
            get
            {
                return this._LastExecutionStartTime;
            }
            set
            {
                this._LastExecutionStartTime = value;
            }
        }
        string global::Sidvall.WorkItemManager.Data.IWorkItem.LastResultMessage
        {
            get
            {
                return this._LastResultMessage;
            }
            set
            {
                this._LastResultMessage = value;
            }
        }
        System.Nullable<global::Sidvall.WorkItemManager.Workflow.WorkItemResultType> global::Sidvall.WorkItemManager.Data.IWorkItem.LastWorkItemResultId
        {
            get
            {
                return this._LastWorkItemResultId;
            }
            set
            {
                this._LastWorkItemResultId = value;
            }
        }
        int global::Sidvall.WorkItemManager.Data.IWorkItem.LogDayCount
        {
            get
            {
                return this._LogDayCount;
            }
            set
            {
                this._LogDayCount = value;
            }
        }
        global::Sidvall.WorkItemManager.Workflow.LogModes global::Sidvall.WorkItemManager.Data.IWorkItem.LogModeId
        {
            get
            {
                return this._LogModeId;
            }
            set
            {
                this._LogModeId = value;
            }
        }
        string global::Sidvall.WorkItemManager.Data.IWorkItem.Name
        {
            get
            {
                return this._Name;
            }
            set
            {
                this._Name = value;
            }
        }
        int global::Sidvall.WorkItemManager.Data.IWorkItem.RetryCount
        {
            get
            {
                return this._RetryCount;
            }
            set
            {
                this._RetryCount = value;
            }
        }
        System.Nullable<System.DateTime> global::Sidvall.WorkItemManager.Data.IWorkItem.RetryTime
        {
            get
            {
                return this._RetryTime;
            }
            set
            {
                this._RetryTime = value;
            }
        }
        int global::Sidvall.WorkItemManager.Data.IWorkItem.SensorLogDayCount
        {
            get
            {
                return this._SensorLogDayCount;
            }
            set
            {
                this._SensorLogDayCount = value;
            }
        }
        long global::Sidvall.WorkItemManager.Data.IWorkItem.WorkerId
        {
            get
            {
                return this._WorkerId;
            }
            set
            {
                this._WorkerId = value;
            }
        }
        string global::Sidvall.WorkItemManager.Data.IWorkItem.WorkItemContext
        {
            get
            {
                return this._WorkItemContext;
            }
            set
            {
                this._WorkItemContext = value;
            }
        }
        System.Nullable<long> global::Sidvall.WorkItemManager.Data.IWorkItem.WorkItemId
        {
            get
            {
                return this._WorkItemId;
            }
            set
            {
                this._WorkItemId = value;
            }
        }
        global::Sidvall.WorkItemManager.Workflow.WorkItemStatus global::Sidvall.WorkItemManager.Data.IWorkItem.WorkItemStatusId
        {
            get
            {
                return this._WorkItemStatusId;
            }
            set
            {
                this._WorkItemStatusId = value;
            }
        }
        System.Nullable<long> global::Sidvall.WorkItemManager.Data.IWorkItem.WorkItemTypeId
        {
            get
            {
                return this._WorkItemTypeId;
            }
            set
            {
                this._WorkItemTypeId = value;
            }
        }
        string global::Sidvall.WorkItemManager.Data.IWorkItem.WorkRetryPolicyContext
        {
            get
            {
                return this._WorkRetryPolicyContext;
            }
            set
            {
                this._WorkRetryPolicyContext = value;
            }
        }
        System.Nullable<long> global::Sidvall.WorkItemManager.Data.IWorkItem.WorkRetryPolicyId
        {
            get
            {
                return this._WorkRetryPolicyId;
            }
            set
            {
                this._WorkRetryPolicyId = value;
            }
        }
        System.Nullable<System.Int32> global::Sidvall.WorkItemManager.Data.IWorkItem.ServerConnectionId
        {
            get
            {
                return this._ServerConnectionId;
            }
            set
            {
                this._ServerConnectionId = value;
            }
        }
        global::Sidvall.WorkItemManager.Data.IWorker global::Sidvall.WorkItemManager.Data.IWorkItem.Worker
        {
            get
            {
                return this._Worker;
            }
            set
            {
                UpdateChildProperty(this._Worker, value);
                this._Worker = value as Worker;
            }
        }
        System.Collections.Generic.IEnumerable<global::Sidvall.WorkItemManager.Data.IWorkItemLog> global::Sidvall.WorkItemManager.Data.IWorkItem.WorkItemLogs
        {
            get
            {
                return this._WorkItemLogs;
            }
        }
        void global::Sidvall.WorkItemManager.Data.IWorkItem.SetWorkItemLogs(Sidvall.Data.IDataRowProvider<global::Sidvall.WorkItemManager.Data.IWorkItemLog> items)
        {
            UpdateChildProperty(this._WorkItemLogs, items);
            this._WorkItemLogs = items as WorkItemLogCollection;
        }
        System.Collections.Generic.IEnumerable<global::Sidvall.WorkItemManager.Data.IWorkItemSensor> global::Sidvall.WorkItemManager.Data.IWorkItem.WorkItemSensors
        {
            get
            {
                return this._WorkItemSensors;
            }
        }
        void global::Sidvall.WorkItemManager.Data.IWorkItem.SetWorkItemSensors(Sidvall.Data.IDataRowProvider<global::Sidvall.WorkItemManager.Data.IWorkItemSensor> items)
        {
            UpdateChildProperty(this._WorkItemSensors, items);
            this._WorkItemSensors = items as WorkItemSensorCollection;
        }
        global::Sidvall.WorkItemManager.Data.IWorkItemType global::Sidvall.WorkItemManager.Data.IWorkItem.WorkItemType
        {
            get
            {
                return this._WorkItemType;
            }
            set
            {
                UpdateChildProperty(this._WorkItemType, value);
                this._WorkItemType = value as WorkItemType;
            }
        }
        System.Collections.Generic.IEnumerable<global::Sidvall.WorkItemManager.Data.IWorkItemWorkCondition> global::Sidvall.WorkItemManager.Data.IWorkItem.WorkItemWorkConditions
        {
            get
            {
                return this._WorkItemWorkConditions;
            }
        }
        void global::Sidvall.WorkItemManager.Data.IWorkItem.SetWorkItemWorkConditions(Sidvall.Data.IDataRowProvider<global::Sidvall.WorkItemManager.Data.IWorkItemWorkCondition> items)
        {
            UpdateChildProperty(this._WorkItemWorkConditions, items);
            this._WorkItemWorkConditions = items as WorkItemWorkConditionCollection;
        }
        global::Sidvall.WorkItemManager.Data.IWorkRetryPolicy global::Sidvall.WorkItemManager.Data.IWorkItem.WorkRetryPolicy
        {
            get
            {
                return this._WorkRetryPolicy;
            }
            set
            {
                UpdateChildProperty(this._WorkRetryPolicy, value);
                this._WorkRetryPolicy = value as WorkRetryPolicy;
            }
        }

        #endregion

        #endregion
        #region Constructors

        public WorkItem()
        {
        }

        public WorkItem(Sidvall.Data.DataRowState? dataRowState)
            : base(dataRowState)
        {
        }

        #endregion
    }
}